<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>订单管理</title>
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/layui/css/layui.css">
</head>
<body>
<div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <header style="height: 100%">
            <div align="left">
                  <div class="layui-tab">
                       <!--   <ul class="layui-tab-title menu_all">
                              <a href="#">
                                  <li class="layui-this" data-id="5">全部订单(<span id="invNumber"></span>)</li></a>

                            <a href="orderLists.html?id="><li data-id="0">待接单(<span id="invNumber2"></span>)</li></a>
                            <a href="#"><li data-id="1">到店自提(<span id="invNumber3"></span>)</li></a>
                            <a href="#"><li data-id="2">外送订单</li></a>
                            <a href="#"><li data-id="3">团购订单</li></a>
                            <a href="#"><li data-id="4">扫码订单</li></a>
                            </ul>-->
                      <ul class="layui-tab-title">
                          <a href="orderList.html"><li>全部订单</li></a>
                          <a href="orderLists.html"><li>待接单</li></a>
                          <a href="orderLists1.html"><li>到店自提</li></a>
                          <a href="orderLists2.html"><li class="layui-this">外送订单</li></a>
                          <a href="orderLists3.html"><li>团购订单</li></a>
                          <a href="orderLists4.html"><li>扫码订单</li></a>
                      </ul>
                        </div>
                <table style="width: 100%">
                    <tr>
                        <td>
                            <form class="form-inline" onsubmit="return false">
                            <div>
                                <div class="form-group" style="float: left">
                                    订单号:
                                    <input id="orderNumber" type="text" class="form-control" placeholder="订单编号">
                                    会员名：
                                    <input id="memberName" type="text" class="form-control" placeholder="昵称/手机号">
                                    下单时间：
                                    <input id="orderTime" name="orderTime" type="text" class="form-control" placeholder="下单时间" onfocus="showDate()">
                                    订单类别：
                                        <select class="form-control input-sm" style="width: 120px" name="identityType" id="identityType">
                                            <option value="0" selected="selected">外送</option>
                                            <option value="1" >团购</option>
                                            <option value="2" >普通商品</option>
                                            <option value="3" >扫码支付</option>
                                        </select>
                                    <button id="searchBt" class="layui-btn layui-btn-sm" ><i
                                            class="layui-icon">&#xe615;</i>筛选
                                    </button>
                                </div>

                                </div>
                            </form>
                        </td>
                    </tr>
                </table>
            </div>
        </header>
        <div>
            <div class="widget-body no-padding">
                <table id="dt-table" class="table table-striped table-bordered table-hover" style="width:100%">
                    <thead>
                    <tr>
                    </tr>
                    <tr>
                        <th style="width: 10%">订单号</th>
                        <th style="width: 10%">商品名</th>
                        <th style="width: 10%">下单会员</th>
                        <th style="width: 10%">下单时间</th>
                        <th style="width: 10%">订单总金额</th>
                        <th style="width: 10%">预计到账金额</th>
                        <th style="width: 10%">配送方式</th>
                        <th style="width: 10%">订单类别</th>
                        <th style="width: 10%">订单状态</th>
                        <th style="width: 10%">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script type="text/javascript" src="../../global/js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../global/js/jq.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../../global/layui/layui.js"></script>
<script type="text/javascript" src="../../global/js/my/permission.js"></script>
<script>
    //时间格式框
    layui.use(['layer', 'laydate'], function () {
        var layer = layui.layer;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#orderTime',
            type: 'datetime',
            format:'yyyy-MM-dd HH:mm:ss'
        });
    });
    //全部订单数
    number();
    function number(){
        $.ajax({
            dataType: 'json',
            type: 'get',
            url: '/goodsOrder/selectByShopId2',
            async:true,
            success: function (data) {
                $('#invNumber').html(data.data);
            }
        });
    }
//menuTab 页面切换
    $(".menu_all li").click(function(){
        $(this).parent().siblings().find("li").removeClass("layui-this");
        $(this).addClass("layui-this");
    //获取当前的绑定id
       /* var id =$(this).attr("data-id");
        console.log(id);*/
    });

</script>
<script type="text/javascript">
   //注意:选项卡 依赖 element 模块,否则无法进行功能性操作
     layui.use('element', function(){
     var element = layui.element;
            });
    var pers = checkPermission();

    var example;

    function init() {
        example =
            $('#dt-table').DataTable({
                "searching": false,
                "processing": false,
                "serverSide": true,
                "language": {
                    "url": "/global/js/plugin/datatables/Chinese.lang"
                },

                "ajax": {
                    "url": "/goodsOrder/selectByShopId",
                    "type": "get",
                    "dataType": "json",
                    "contentType": "application/json;charset=utf-8",
                    "data": function (d) {
                        d.name = $('#shopsId').val();

                    },
                    "error": function (xhr, textStatus, errorThrown) {
                        var msg = xhr.responseText;
                        console.log(msg);
                        var response = JSON.parse(msg);
                        var code = response.code;
                        var message = response.message;
                        if (code == 400) {
                            layer.msg(message);
                        } else if (code == 401) {
                            localStorage.removeItem("token");
                            layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function () {
                                location.href = '/login.html';
                            });
                        } else if (code == 403) {
                            console.log("未授权:" + message);
                            layer.msg('未授权');
                        } else if (code == 500) {
                            layer.msg('系统错误:' + message);
                        }
                    }
                },
                "dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
                "columns": [
                    {"data": "tradeNo", "defaultContent": ""},
                    {"data": "goodsName", "defaultContent": ""},
                    {"data": "userId", "defaultContent": ""},
                    {"data": "createTime", "defaultContent": "",
                                       "render":function(data) {
                                           if(data==null || data==""){
                                               return data;
                                           }
                                         var dateee = new Date(data).toJSON();
                                         var date=new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
                                         data=date
                                         return data;
                                       }},
                    {"data": "payMoney","defaultContent": ""},
                    {"data": "payAmount","defaultContent": ""},
                    {"data": "sendMode","defaultContent": ""},

                    {"data": "orderType", "defaultContent": "",
                        "render": function (data, type, row) {
                            console.log(data)
                            if (data == 0) {
                                data = "身份证"
                            } else if (data == 2) {
                                data = "护照"}
                            return data;}},

                    {"data": "orderStatus", "defaultContent": "",
                        "render": function (data, type, row) {
                            console.log(data)
                            data=0
                            if (data == 0) {
                                 return "<button id='editrow' class='btn btn-primary' type='button'  style='display: block;margin: 0 auto;text-align: center'><i class='fa fa-edit'></i>待付款</button>"
                            } else if (data == 1) {
                                return "待发货 待使用"
                            } else if (data==2) {
                                return"待收货"
                            }else if(data ==3){
                                return "已完成 已使用"
                            }else{
                                return data;
                            }
                            }
                            },
                    {
                        "data": "",
                        "defaultContent": "",
                        "orderable": false,
                        "render": function (data, type, row) {
                            return  "<button id='editrow' class='btn btn-primary' type='button'  onclick='showId("+row['tradeNo']+")' style='display: block;margin: 0 auto;text-align: center'><i class='fa fa-edit'></i>查看</button>"
                        }
                    },

                ],
                "order": [[2, "desc"]]

            });
    }
    //查看
function showId(tradeNo){
    window.location.href="../order/Detailspage.html?tradeNo="+tradeNo;
};

    layui.use('layer', function () {
    var layer = layui.layer;
});

$("#searchBt").click(function () {
    example.ajax.reload();
});
    init();
</script>